from enum import Enum

class ErrorCode(Enum):
    SUCCESS = (0, "成功")
    SERVER_ERROR = (500, "服务器内部错误")
    INVALID_INPUT = (400, "Invalid input data")
    NOT_FOUND = (404, "资源未找到")
    UNAUTHORIZED = (401, "未授权")
    FORBIDDEN = (403, "禁止访问")
    # 用户相关错误码（1000以上）
    USER_ALREADY_EXISTS = (1001, "用户已存在")
    USER_NOT_FOUND = (1002, "用户不存在")
    USER_PASSWORD_ERROR = (1003, "用户名或密码错误")
    USER_TOKEN_INVALID = (1004, "无效token")
    USER_TOKEN_EXPIRED = (1005, "token已过期")
    # 房源图片相关
    PARAM_MISSING = (1006, "缺失参数")
    IMAGE_NOT_FOUND = (1007, "图片未找到")
    # 订单相关
    PARAM_INVALID = (1008, "日期格式错误")
    ORDER_NOT_FOUND = (1009, "订单不存在")
    PERMISSION_DENIED = (1010, "没有权限查看")
    ORDER_STATUS_INVALID = (1011, "订单状态非法")

    #房源相关错误码（2000以上）
    HOUSE_NOT_FOUND = (2001, "房源不存在")
    REVIEW_NOT_FOUND = (2002, "评价不存在")

    def __init__(self, code, msg):
        self.code = code
        self.msg = msg